#include <sys/types.h>          
#include <sys/socket.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#include <pthread.h>
#include <fcntl.h>
#include <vector>
using namespace std;
#include "serverThread.h"
#include "serverSocket.h"
#include "server.h"
#include "serverException.h" 
#include "data.h"

#define DEFAULT_PORT 6666
#define DEFAULT_IP "127.0.0.1"


//无参服务器初始化
Server::Server(){
	socket = NULL;
    thread = NULL;
	char server_ip[32] = DEFAULT_IP;//宏定义IP "127.0.0.1"
    short server_port = DEFAULT_PORT;//宏定义端口号 6666
	socket = new ServerSocket(server_ip,server_port);//new 一个文件传输协议
	printf("服务器初始化成功!");
}
//有参服务器初始化
Server::Server(char *server_ip,short server_port){
	socket = NULL;
    thread = NULL;
	socket = new ServerSocket(server_ip,server_port);//new 一个文件传输协议
	printf("服务器初始化成功!");
}
//析构函数 销毁服务器
Server::~Server(){
	delete thread;
    	thread = NULL;
    	delete socket;
    	socket = NULL;
}

//启动服务器数据采集
void Server::dataMine(){
	socket->acceptClient();//接收客户端，等待客户端连接
}


